import React from 'react';
import './index.less';
import {bindAction, bindModel, render} from 'react-division';

import ModelListModel from './models/ModelList';
import ModelListAction from './actions/ModelList';
import tableCreate from 'lib/ConfigTable';

bindAction({
    modelListA: ModelListAction
});

bindModel({
    modelListM: ModelListModel
});

const ConfigTable = tableCreate({
    modelName: 'modelListM',
    actionName: 'modelListA'
});


export default render({
    models: ['modelListM'],
    actions: ['modelListA']
})(class extends React.Component {
    constructor(props) {
        super(props);
        this.props.action.modelListA.getModelList();
    }

    componentDidMount() {
    }

    render() {
        const {action} = this.props;

        return (
            <div className="model-list-page">
                <ConfigTable 
                    operation={[{
                        label: '编辑模型信息',
                        visible: true,
                        onClick: action.modelListA.editModelInfo
                    }, {
                        label: '编辑模型数据',
                        visible: true,
                        onClick: action.modelListA.editModelData
                    }, {
                        label: '上传模型',
                        visible: true,
                        onClick: action.modelListA.uploadModel
                    }, {
                        label: '删除模型',
                        visible: true,
                        onClick: action.modelListA.deleteModel,
                        tips: '确定要删除该模型吗？'
                    }, {
                        label: '生成模型',
                        visible: true,
                        onClick: action.modelListA.makeModelCode
                    }]}
                />
            </div>
        );
    }
});